import torch


a = torch.randint(1, 5, (2, 3))
b = torch.randint(1, 5, (2, 3))
a = a.float()

"""加法"""
# print(a + b)
# print(torch.add(a, b))

"""out可以规定保存的结果位置"""
# result = torch.zeros(3, 2)
# print(torch.add(a, b, out=result))

# a=a+b
# 注意任何使张量 tensor 会发生变化的操作都有一个前缀 '_', 列如: a.add_(),b.sub_()
# print(a.add_(b))

tensor = torch.ones(3, 6)
print(tensor)
print(a)
print(torch.matmul(a, tensor))  # 2*3 3*5 = 2*5
# a.T 转置
print(a.T)
